package wwl.lsf.orc;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

public class OCR {

    public static void main(String[] args) throws TesseractException {

        File imageFile1 = new File("C:\\Users\\Administrator\\Desktop\\88888.jpg");//读取图片数字
//Tesseract instance = new Tesseract();
        ITesseract instance = new Tesseract();
        instance.setDatapath("C:\\Program Files\\Tesseract-OCR\\tessdata"); //上面第3步的目录
        instance.setLanguage("eng");//英文库识别数字比较准确

        String s = instance.doOCR(imageFile1);
        System.out.println("s = " + s);

//        String content = instance.doOCR(imageFile1).replace("\n", "");
//        content = content.replace(" ", "");
//        System.out.println("content = " + content);
    }
}
